package it.cast.wechat.service.ServiceImpl;

import it.cast.wechat.mapper.UserMapper;
import it.cast.wechat.pojo.User;
import it.cast.wechat.pojo.UserExample;
import it.cast.wechat.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;

    @Override
    public User getById(String id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public void insertUser(String id) {
        User user = new User();
        user.setId(id);
        userMapper.insert(user);
    }

    @Override
    public List<User> getAll() {
        UserExample example = new UserExample();
        UserExample.Criteria criteria = example.createCriteria();
        criteria.andIdIsNotNull();
        List<User> users = userMapper.selectByExample(example);
        return users;
    }
}
